<template>
	<view>
		<u-navbar title-color="#000" back-icon-color="#000000" :border-bottom="false" :is-fixed="true" :title="'菜单中心'"></u-navbar>
		<u-grid col="3" :border="false">
			<u-grid-item v-for="(item,index) in menuList" :name="item.title" :key="index" :index="index" @click="itemClick(item)">
				<u-badge v-if="item.badge!=0" :count="item.badge" :offset="[20,30]"></u-badge>
				<u-icon :name="item.icon" :color="item.color" custom-prefix="el-icon-if" :size="46"></u-icon>
				<view class="grid-text">{{item.title}}</view>
			</u-grid-item>
		</u-grid>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuList:[
					{
						badge:0,
						icon:'jianzhu',
						color:"#5098FF",
						title:"建筑信息",
						path:'/pages/index/build/list',
					},
					{
						badge:0,
						icon:'huoqing',
						color:"#5098FF",
						title:"火情消息",
						path:'/pages/index/fireInfo/list',
					},
					{
						badge:0,
						icon:'huoqing',
						color:"#5098FF",
						title:"演练信息",
						path:'/pages/index/drill/list',
					},
					{
						badge:0,
						icon:'taskpool',
						color:"#5098FF",
						title:"任务领取",
						path:'/pages/index/task/receive',
					},
					{
						badge:0,
						icon:'mytask',
						color:"#5098FF",
						title:"我的任务",
						path:'/pages/index/task/list',
					},
					{
						badge:0,
						icon:'xunjian',
						color:"#5098FF",
						title:"维保工单",
						path:'/pages/index/workorder/maintenance/list',
					},
					{
						badge:0,
						icon:'xunjian',
						color:"#5098FF",
						title:"故障工单",
						path:'/pages/index/workorder/fault/list',
					},
					{
						badge:0,
						icon:'mytask',
						color:"#5098FF",
						title:"维保任务",
						path:'/pages/index/workorder/task/list',
					},
					{
						badge:0,
						icon:'xunjian',
						color:"#5098FF",
						title:"消防隐患",
						path:'/pages/index/firedanger/index',
					},
					{
						badge:0,
						icon:'xunjian',
						color:"#5098FF",
						title:"企业隐患",
						path:'/pages/index/enterprise/list',
					}
				]
			}
		},
		computed:{
			hiddenButton(){
				let roleCode = this.$store.getters.roleCode;
				return roleCode=="XFZD-ADMIN"||roleCode=="XT-ADMIN"||roleCode=="ZD-ADMIN"||roleCode=="DD-ADMIN"||roleCode=="JW-ADMIN"||roleCode=="XZ-ADMIN"
			}
		},
		onShow() {
			this.menuList=[
				{
					badge:0,
					icon:'jianzhu',
					color:"#5098FF",
					title:"建筑信息",
					path:'/pages/index/build/list',
				},
				{
					badge:0,
					icon:'yujin',
					color:"#5098FF",
					title:"预警信息",
					path:'/pages/index/alarm/list',
				},
				{
					badge:0,
					icon:'huoqing',
					color:"#5098FF",
					title:"火情消息",
					path:'/pages/index/fireInfo/list',
				},
				{
					badge:0,
					icon:'huoqing',
					color:"#5098FF",
					title:"演练信息",
					path:'/pages/index/drill/list',
				},
				{
					badge:0,
					icon:'taskpool',
					color:"#5098FF",
					title:"任务领取",
					path:'/pages/index/task/receive',
				},
				{
					badge:0,
					icon:'mytask',
					color:"#5098FF",
					title:"我的任务",
					path:'/pages/index/task/list',
				},
				{
					badge:0,
					icon:'xunjian',
					color:"#5098FF",
					title:"维保工单",
					path:'/pages/index/workorder/maintenance/list',
				},
				{
					badge:0,
					icon:'mytask',
					color:"#5098FF",
					title:"维保任务",
					path:'/pages/maintenance/task/list',
				},
				{
					badge:0,
					icon:'xunjian',
					color:"#5098FF",
					title:"消防隐患",
					path:'/pages/index/firedanger/index',
				},
				{
					badge:0,
					icon:'xunjian',
					color:"#5098FF",
					title:"隐患企业",
					path:'/pages/index/enterprise/list',
				},
				{
					badge:0,
					icon:'xunjian',
					color:"#5098FF",
					title:"异常企业",
					path:'/pages/index/enterprise/abnormalEnterpriseList',
				},
			]
			if(this.hiddenButton){
				this.addMenu()
			}
		},
		methods: {
			itemClick(item){
				if(item.title=="发起演练"){
					//判断用户的角色数据
					if(this.$store.getters.roleCode=="XZ-ADMIN"){
						uni.navigateTo({
							url:item.path
						})
					}else{
						uni.navigateTo({
							url:"/pages/index/choice/choice"
						})
					}
				}else{
					uni.navigateTo({
						url:item.path
					})
				}
			},
			addMenu(){
				this.menuList.push({
					badge:0,
					icon:'xunjian',
					color:"#5098FF",
					title:"发起演练",
					path:'/pages/index/drill/drillNotice'})
			},
			OpenTel(){
				window.native.getLocation(res=>{
					console.log(res)
				})
			},
			test(){
				window.native.h5Camera(res=>{
					
				})
				window.native.getUri(res=>{
					console.log(res)
				})
			}
		}
	}
</script>

<style>

</style>
